#include <iostream>
#include <string>
using namespace std;

class Solution {
public:
    bool IsLetterOrNumber (char ch)
    {
        return (ch>='a'&&ch<='z')||(ch>='A'&&ch<='Z')||(ch>='0'&&ch<='9');
    }

    bool isPalindrome(string s) {
    for(auto& ch:s)
    {
        if(ch>='a'&&ch<='z')
            ch-=32;
    }
    int begin=0;
    int end=s.size()-1;
    while(begin<end)
    {
        while(begin<end&&!IsLetterOrNumber(s[begin]))
            begin++;
        while(begin<end&&!IsLetterOrNumber(s[end]))
            end--;
        if(s[begin]!=s[end])
        {
           return false;
        }
        else
        {
            begin++;
            end--;
        }    
    }
    return true; 
    }
};